// API基础配置
export const API_BASE_URL = typeof window !== 'undefined' 
  ? (window as any).location?.origin?.includes('localhost') 
    ? 'http://localhost:8080/api' 
    : 'http://localhost:8080/api'
  : 'http://localhost:8080/api'

// API端点配置
export const API_ENDPOINTS = {
  // 用户相关
  AUTH: {
    LOGIN: '/auth/login',
    REGISTER: '/auth/register',
    LOGOUT: '/auth/logout',
    PROFILE: '/auth/profile',
    REFRESH: '/auth/refresh',
  },
  
  // 产品相关
  PRODUCTS: {
    LIST: '/products',
    DETAIL: '/products',
    SEARCH: '/products/search',
    CATEGORIES: '/categories',
  },
  
  // 订单相关
  ORDERS: {
    LIST: '/orders',
    CREATE: '/orders',
    DETAIL: '/orders',
    CANCEL: '/orders',
    STATS: '/orders/stats/my'
  },
  
  // 支付相关
  PAYMENT: {
    CREATE: '/payment/create',
    SIMULATE: '/payment/simulate/success'
  },
  
  // 购物车相关
  CART: {
    LIST: '/cart',
    ADD: '/cart/add',
    UPDATE: '/cart/update',
    REMOVE: '/cart/remove',
    CLEAR: '/cart/clear',
  },
  
  // 溯源相关
  TRACE: {
    QUERY: '/trace',
    DETAIL: '/trace',
  },
  
  // 文件上传
  UPLOAD: {
    IMAGE: '/upload/image',
  },
}

// HTTP状态码
export const HTTP_STATUS = {
  OK: 200,
  CREATED: 201,
  BAD_REQUEST: 400,
  UNAUTHORIZED: 401,
  FORBIDDEN: 403,
  NOT_FOUND: 404,
  INTERNAL_SERVER_ERROR: 500,
}

// 用户类型
export const USER_TYPES = {
  INDIVIDUAL: 'INDIVIDUAL',
  ENTERPRISE: 'ENTERPRISE',
  ADMIN: 'ADMIN',
}

// 订单状态
export const ORDER_STATUS = {
  PENDING: 'PENDING',
  PAID: 'PAID',
  SHIPPED: 'SHIPPED',
  DELIVERED: 'DELIVERED',
  CANCELLED: 'CANCELLED'
};

// 产品状态
export const PRODUCT_STATUS = {
  ACTIVE: 'ACTIVE',
  INACTIVE: 'INACTIVE',
  OUT_OF_STOCK: 'OUT_OF_STOCK',
}

// 本地存储键名
export const STORAGE_KEYS = {
  TOKEN: 'seafood_token',
  USER: 'seafood_user',
  CART: 'seafood_cart',
}

// 分页配置
export const PAGINATION = {
  DEFAULT_PAGE_SIZE: 12,
  DEFAULT_CURRENT: 1,
}

// 图片配置
export const IMAGE_CONFIG = {
  DEFAULT_PRODUCT: '/images/default-product.jpg',
  DEFAULT_AVATAR: '/images/default-avatar.jpg',
  UPLOAD_MAX_SIZE: 5 * 1024 * 1024, // 5MB
  ALLOWED_TYPES: ['image/jpeg', 'image/png', 'image/gif', 'image/webp'],
}